<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>商品信息管理</title>
	</head>
	<body>
		<center>
			<h3>添加商品信息</h3>
			<table width="380" border="0">
				<form action="action.php?a=insert" method="post" enctype="multipart/form-data">
					<tr>
						<td>商品类别</td>
						<td>
							<select name="typeid">
								<?php 
									//导入数据库配置文件
									require("../../public/config.php");
									//连接数据库
									$link = @mysqli_connect(HOST,USER,PASS,DBNAME)or die("数据库连接失败！");
									//设置数据库的编码
									mysqli_set_charset($link,"utf8");
									$sql = "select * from type order by concat(path,id)";
									$result = mysqli_query($link,$sql);
									//解析字符值并遍历输出
									
									while($row=mysqli_fetch_assoc($result)){
										$m = substr_count($row['path'],",")-1;//计算逗号出现的次数
										$str = str_repeat("&nbsp;",$m*2);//输出空格
										
										$disabled = ($row['pid']==0)?"disabled":"";
										echo "<option $disabled value='{$row['id']}'>";
										echo "{$str}|--{$row[name]}";
										echo "</option>";
									}
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td>商品名称</td>
						<td><input type="text" name="goods"></td>
					</tr>
					<tr>
						<td>生产厂家</td>
						<td><input type="text" name="company"></td>
					</tr>
					<tr>
						<td>商品图片</td>
						<td><input type="file" name="pic"></td>
					</tr>
					<tr>
						<td>商品价格</td>
						<td><input type="text" name="price"></td>
					</tr>
					<tr>
						<td>商品存量</td>
						<td><input type="text" name="store"></td>
					</tr>
					<tr>
						<td>商品简介</td>
						<td><textarea cols="30" rows="5" name="descr"></textarea></td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<input type="submit" value="提交">
							<input type="reset" value="重置">
						</td>
					</tr>
				</form>
			</table>
		</center>
	</body>
</html>